<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use DateTimeInterface;

class Scanscoresign extends Model
{
    protected $table = 'scan_score_sign';
    protected $primaryKey = 'id';

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'm月d日H点i分');
    }
    
    public static function getScanScoreSign($openid)
    {
        return self::where("openid",$openid)->first();
    }

    public static function updateScanScoreSign($openid,$key)
    {
        return self::where("openid",$openid)->update([$key=>time()]);
    }

    public static function createScanScoreSign($openid)
    {
        return self::insert(["openid"=>$openid,"day_1"=>time(),"created_at"=>time()]);
    }
}